package com.example.nna.voz;

import java.util.ArrayList;

import android.app.Activity;
import android.os.Handler;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.nna.main.R;

public class MylistView1 extends MylistView {
	private ArrayList<contain1> contains;
	public MylistView1(Activity context,Handler handler, ArrayList<contain1> contains) {  
		 super(context,handler, new ArrayList<contain>(contains));         
		 this.contains = contains;
	}  
	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		final int pos;
		pos = position;
        if(convertView==null)  
        {  
            holder = new ViewHolder();  
            convertView = inflater.inflate(R.layout.list_item, null);  
            holder.layout = (RelativeLayout) convertView.findViewById(R.id.listitem1);  
            holder.imgView = (ImageView) convertView.findViewById(R.id.image);  
            holder.txtView1 = (TextView) convertView.findViewById(R.id.text1);  
            holder.txtView2 = (TextView) convertView.findViewById(R.id.text2);  
            holder.txtView3 = (TextView) convertView.findViewById(R.id.text3);
            holder.txtView4 = (TextView) convertView.findViewById(R.id.text4);

            convertView.setTag(holder);  
        }  
        else  
            holder=(ViewHolder)convertView.getTag();  
        
        if((contains.get(position).Image()==null)&&(contains.get(position).Posts()==null)){
        	holder.txtView1.setTextColor(context.getResources().getColor(R.color.white));
        	holder.layout.setBackgroundResource(R.color.vozTcat);
        	holder.txtView1.setText(contains.get(position).Forum()); 
        	holder.txtView2.setText("");  
            holder.txtView3.setText("");  
            holder.txtView4.setText("");
        	holder.txtView2.setVisibility(View.GONE); 
            holder.txtView3.setVisibility(View.GONE); 
            holder.txtView4.setVisibility(View.GONE); 
        }else{
        	
        	holder.txtView2.setVisibility(View.VISIBLE); 
            holder.txtView3.setVisibility(View.VISIBLE); 
            holder.txtView4.setVisibility(View.VISIBLE); 
            holder.layout.setBackgroundResource(R.color.vozThread);
        	holder.txtView1.setTextColor(context.getResources().getColor(R.color.black));
        	holder.txtView2.setTextColor(context.getResources().getColor(R.color.black));
        	holder.txtView3.setTextColor(context.getResources().getColor(R.color.black));
        	holder.txtView4.setTextColor(context.getResources().getColor(R.color.black));
        	holder.txtView1.setText(contains.get(position).Forum());
            holder.txtView2.setText(contains.get(position).LastPost());  
            holder.txtView3.setText(contains.get(position).Threads());  
            holder.txtView4.setText(contains.get(position).Posts());  
        }
        holder.txtView1.setTextSize(mTextSize1);
        holder.txtView2.setTextSize(mTextSize2);
        holder.txtView3.setTextSize(mTextSize3);
        holder.txtView4.setTextSize(mTextSize4);
        holder.imgView.setImageBitmap(contains.get(position).Image());

        holder.txtView1.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				mHandler.obtainMessage(Voz.MSG_PAGE2,pos).sendToTarget();
			}
		});

        holder.txtView2.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				//mHandler.obtainMessage(Voz.MSG_PAGE3, pos).sendToTarget();
			}
		});
		return super.getView(position, convertView, arg2);
	}

}
